package design.simdi.code.final_paper.core.entities;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

@Entity
@Table(name = "persons")
@AttributeOverrides( { @AttributeOverride(name = "id", column = @Column(name = "Person_Id")) })
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Person extends ApplicationEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private String nume;
	private String prenume;
	private String CNP;
	private User user;
	private Student student;
	private Profesor profesor;
	private Absolvent absolvent;

	/**
	 * @return the nume
	 */
	@Column(length = 250, nullable = false, name = "Nume")
	public String getNume() {
		return nume;
	}

	/**
	 * @param nume
	 *            the nume to set
	 */
	public void setNume(String nume) {
		this.nume = nume;
	}

	/**
	 * @return the prenume
	 */
	@Column(length = 250, nullable = false, name = "Prenume")
	public String getPrenume() {
		return prenume;
	}

	/**
	 * @param prenume
	 *            the prenume to set
	 */
	public void setPrenume(String prenume) {
		this.prenume = prenume;
	}

	/**
	 * @return the cNP
	 */
	@Column(length = 250, nullable = true, name = "CNP")
	public String getCNP() {
		return CNP;
	}

	/**
	 * @param cNP
	 *            the cNP to set
	 */
	public void setCNP(String cNP) {
		CNP = cNP;
	}

	public Person() {
	}

	/**
	 * @param user
	 *            the user to set
	 */
	public void setUser(User user) {
		this.user = user;
	}

	/**
	 * @return the user
	 */
	@OneToOne
	@JoinColumn(name = "User_Fk")
	public User getUser() {
		return user;
	}

	public String toString() {
		return nume + " " + prenume;
	}

	public void setStudent(Student student) {
		this.student = student;
	}

	@OneToOne
	@JoinColumn(name = "Student_Fk")
	public Student getStudent() {
		return student;
	}

	public void setProfesor(Profesor profesor) {
		this.profesor = profesor;
	}

	@OneToOne
	@JoinColumn(name = "Profesor_Fk")
	public Profesor getProfesor() {
		return profesor;
	}

	public void setAbsolvent(Absolvent absolvent) {
		this.absolvent = absolvent;
	}

	@OneToOne
	@JoinColumn(name = "Absolvent_Fk")
	public Absolvent getAbsolvent() {
		return absolvent;
	}
}
